import App from './App.tsx'
import React, { useState } from 'react'
import styled from "styled-components";
import { useParams } from 'react-router-dom';

function AppContainer() {
    const [amount, setAmount] = useState(15);
    const [refreshKey, setRefreshKey] = useState(0); // 添加一个新的状态
    const params = useParams();
    debugger
    console.log(params); // 打印路由参数
    const handleAmountChange = (event: React.ChangeEvent<HTMLInputElement>) => {
      setAmount(Number(event.target.value));
    };
  
    const handleRefresh = () => { // 添加一个新的函数来改变 refreshKey 的值
      setRefreshKey(oldKey => oldKey + 1);
    };

    return (
        <React.StrictMode>
         
          <App 
          handleRefresh={handleRefresh}
          handleAmountChange={handleAmountChange} 
          amount={amount} key={refreshKey} 
          /> {/* 添加 key prop 来触发组件的重新挂载 */}
        </React.StrictMode>
      );
}
export default AppContainer;